import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
  rewrites: async () => {
    return [
      {
          // /api/ URL设置要与flask中restful地址一致
          source: '/api/:path*',
          destination:
          // ip:5000 对应到 flask中
          // 访问next.js的http://localhost:3000/api/hello 会映射到fask的 http://127.0.0.1:5000/api/hello
          process.env.NODE_ENV === 'development'
              ? 'http://127.0.0.1:5000/api/:path*'
              : '/api/',
      },
    ]
  },
};

export default nextConfig;
